package testivrs.testivrs;



public class StudentReg
{

    public boolean doPost(String name, String rollno, String mobno)
     {
        int flag=0;

        String s[]={"1", "2", "3", "4", "5", "6", "7", "8", "9", "&", "\"", "%", "$"};

      
            for(int j=0; j<s.length; j++)
                if(name.contains(s[j]))
                {
                    System.out.println("Invalid character in name");
                   flag=1;
                }
        try
        {int r=Integer.parseInt(rollno);

        }
        catch(Exception ex)
        {
            if(rollno.startsWith("Mt"))
            {}

            else{
                System.out.println("Invalid roll no");
                flag=1;
            }


        }

       
            Long r=Long.parseLong(mobno);

        
        /*catch(Exception ex)
        {
           // ex.printStackTrace();
        	System.out.println("Invalid mobile no");
            flag=1;
        }*/
        if(mobno.length()!=10)
        {
            System.out.println("Invalid mobile no");
            flag=1;
        }

        if(flag==1)
        {
            return false;
        }

        
        /*for(int i=0; i<name.length(); i++)
        {
            if(name.charAt(i)-"0"<65||(name.charAt(i)-"0">92&&name.charAt(i)-"0"<97)||name.charAt(i)-"0">122)
                System.out.println("invalid character");
        }

            if(name.contains("=")||name.contains("\""))
            {
                System.out.println("Invalid characters in name");
            }*/
            Database_access ob = null;
            
           try{
               ob = new Database_access();
            
             
            int pin=129845;
           
             ob.StudentReg(name, mobno,pin,rollno);

             System.out.println("You have been successfully registered. The pin for accessing IVRS has been mailed to your email id. Thankyou!");
             return true;
           } catch (Exception ex) {
             System.out.println("failed");
             //ex.printStackTrace();
             return false;

           

        }
            
           
    }

     
  
   

}
